Skip to content

feat(coverage): add auto-updating test coverage badge#63

Merged
Bccorb merged 1 commit into
mainfrom
feat/coverage-badge
Jul 17, 2026
Merged

feat(coverage): add auto-updating test coverage badge#63
Bccorb merged 1 commit into
mainfrom
feat/coverage-badge

Conversation

@Bccorb

@Bccorb Bccorb commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Closes #49.

Summary

Adds a line-coverage badge to the README that stays in sync automatically, mirroring the approach in seamless-auth-api.

What's included

  • Vitest coverage: added @vitest/coverage-v8 and a coverage block in vitest.config.ts. The test include stays src/**/*.test.ts and coverage include is src/**/*.ts, so the run never sweeps the Playwright specs under verify/ (per the note on Add a dynamic test coverage badge, generated as part of the PR process #49).
  • Scripts: coverage (vitest run --coverage --fileParallelism=false) and coverage:badge (node ./scripts/updateCoverageBadge.mjs, ported from the sibling repo).
  • Badge asset: resources/coverage-badge.svg, generated from coverage/coverage-summary.json, referenced in README.md as ![coverage](resources/coverage-badge.svg).
  • Sync mechanism: a Husky pre-commit hook regenerates and stages the badge on every commit, then rebuilds. coverage/ is gitignored; only the SVG and README are committed.

Decision (task: "which mechanism do we standardize on")

We went with the Husky pre-commit hook rather than a CI staleness check, matching seamless-auth-api so the two repos behave the same. This repo had no Husky before, so husky is added as a dev dependency and wired via the prepare script. The hook is adapted to this repo's available scripts (it has no lint/format/typecheck scripts, so those steps from the sibling's hook are omitted):

npm run coverage
npm run coverage:badge
git add README.md resources/coverage-badge.svg
npm run build

Documented in AGENTS.md under Conventions.

Checks

  • npm run build passes
  • npm test passes (94 passed, 4 skipped)
  • Verified the pre-commit hook runs end-to-end (this PR's own commit regenerated the badge)

Current line coverage: 23.2%. No changeset: this is dev tooling and does not change the published CLI behavior.

Enable Vitest coverage (@vitest/coverage-v8) scoped to src/**/*.ts, add
coverage and coverage:badge scripts, and generate resources/coverage-badge.svg
from coverage/coverage-summary.json. A Husky pre-commit hook regenerates and
stages the badge on every commit so the committed SVG always reflects the
latest run, mirroring seamless-auth-api.

Closes #49
@Bccorb
Bccorb merged commit 7b581ee into main Jul 17, 2026
1 check failed
Bccorb added a commit that referenced this pull request Jul 17, 2026
feat(coverage): add auto-updating test coverage badge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a dynamic test coverage badge, generated as part of the PR process

1 participant